package com.xxx.kjds.serviceImpl;


import com.xxx.kjds.entity.Brand;
import com.xxx.kjds.entity.BrandExample;
import com.xxx.kjds.mapper.BrandMapper;
import com.xxx.kjds.service.BrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandServiceImpl implements BrandService {
    @Autowired
    private BrandMapper brandMapper;

    @Override
    public long countByExample(BrandExample example) {
        return brandMapper.countByExample(example);
    }

    @Override
    public int deleteByExample(BrandExample example) {
        return brandMapper.deleteByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return brandMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Brand record) {
        return brandMapper.insert(record);
    }

    @Override
    public int insertSelective(Brand record) {
        return brandMapper.insertSelective(record);
    }

    @Override
    public List<Brand> selectByExample(BrandExample example) {
        return brandMapper.selectByExample(example);
    }

    @Override
    public Brand selectByPrimaryKey(Integer id) {
        return brandMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByExampleSelective(Brand record, BrandExample example) {
        return brandMapper.updateByExampleSelective(record, example);
    }

    @Override
    public int updateByExample(Brand record, BrandExample example) {
        return brandMapper.updateByExample(record, example);
    }

    @Override
    public int updateByPrimaryKeySelective(Brand record) {
        return brandMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Brand record) {
        return brandMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<Brand> selectAllByMid(Integer mid) {
        BrandExample brandExample = new BrandExample();
        BrandExample.Criteria criteria = brandExample.createCriteria();
        criteria.andMvoIdEqualTo(mid);
        return brandMapper.selectByExample(brandExample);
    }

    @Override
    public Brand selectByName(String name) {
        BrandExample brandExample = new BrandExample();
        BrandExample.Criteria criteria = brandExample.createCriteria();
        criteria.andNameEqualTo(name);
        List<Brand> list = brandMapper.selectByExample(brandExample);
        if (list.size() > 0) {
            return list.get(0);
        }
        return null;
    }

    @Override
    public int deleteByName(String name) {
        BrandExample brandExample = new BrandExample();
        BrandExample.Criteria criteria = brandExample.createCriteria();
        criteria.andNameEqualTo(name);
        return brandMapper.deleteByExample(brandExample);
    }
}
